#!/bin/bash
#  linux/mac/window(mingw) 平台打包脚本, 打包成一个可执行文件
mkdir ../target
which pyinstaller
if [ $? -ne 0 ];then
  pip3 install pyinstaller
fi

pyinstaller=`which pyinstaller`
if [ "${pyinstaller}" == "" ];then
   pyinstaller=$1
fi

if [ "${pyinstaller}" == "" ];then
   echo "pyinstaller not found, please special the path manual."
   exit
fi

out_path=../target
main_file=../main.py
logo_file=../favicon.ico


#  build app
"${pyinstaller}" --hidden-import=queue  -wyF --distpath ${out_path} -n echat -i ${logo_file}  ${main_file} -w

if [ -f ${out_path}/app.tar.gz ];then
  rm -f ${out_path}/app.tar.gz
fi

tar -cvzf app.tar.gz  ${out_path}
cp -f app.tar.gz ${out_path}
rm -f app.tar.gz
